#include <iostream>
#include <cstring>
using namespace std;
char pre[10000];
char in[10000];
void solve(int prel,int prer,int inl,int inr)
{
    int i;
    if(prel>prer)
    {
        return;
    }
    char ch=pre[prel];
    for(i=inl;i<=inr;i++)
    {
        if(in[i]==ch)
            break;
    }
    int lenl=i-inl;
    int lenr=inr-i;
    solve(prel+1,prel+lenl,inl,lenl+inl-1);
    solve(prel+lenl+1,prer,lenl+inl+1,inr);
    cout<<ch;
}
int main()
{
    cin>>(pre+1)>>(in+1);
    solve(1,strlen(pre+1),1,strlen(in+1));
    return 0;
}
